import { Component, OnChanges, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import Singleton from "../services/singleton"


@Component({
  selector: 'app-nav-bar',
  templateUrl: './nav-bar.component.html',
  styleUrls: ['./nav-bar.component.scss']
})
export class NavBarComponent implements OnInit, OnChanges{
  username: string = "";
  singleton_username: Singleton;
  constructor(
    private location: Location,
    private route: ActivatedRoute,
    private router: Router,
  ) { }
  ngOnInit(): void {
    console.log('sdsdsd');
    this.singleton_username = Singleton.getInstance();
    this.username = this.singleton_username.getUserName();
    console.log(this.username);
  }

  ngOnChanges(): void {
    console.log('sdsds2');
    this.singleton_username = Singleton.getInstance();
    this.username = this.singleton_username.getUserName();
    console.log(this.username);
  }

  isLogin(){
    if (this.location.path() === '/login'){
      return true;
    }
    else {
      return false;
    }
  }
}
